{% set pypi_name = 'octavia-tempest-plugin' %}
{% set source=fetch_source('https://tarballs.openstack.org/octavia-tempest-plugin/octavia-tempest-plugin-1.5.0.tar.gz') %}
{% set upstream_version = upstream_version() %}
{% set rpm_release = '1' %}

Name:          {{ py2name(py_versions='py3') }}
Version:       {{ py2rpmversion() }}
Release:       {{ py2rpmrelease() }}
Summary:       Tempest plugin for the Octavia project
License:       {{ license('Apache-2.0') }}
Group:         Development/Languages/Python
URL:           https://docs.openstack.org/{{ pypi_name }}
Source0:       {{ source|basename }}
BuildRequires: openstack-macros
BuildRequires:  {{ py3('pbr') }}
Requires:      {{ py2pkg('Tempest') }}
Requires:      {{ py3('cryptography') }}
Requires:      {{ py3('oslo.config') }}
Requires:      {{ py3('oslo.log') }}
Requires:      {{ py3('oslo.utils') }}
Requires:      {{ py3('oslotest') }}
Requires:      {{ py3('pbr') }}
Requires:      {{ py3('python-dateutil') }}
Requires:      {{ py3('requests') }}
Requires:      {{ py3('six') }}
Requires:      {{ py3('tenacity') }}
%if 0%{?suse_version}
BuildRequires:  golang-packaging
%else
BuildRequires:  golang
%endif

%description
This project contains the Tempest plugin for the Octavia project for
OpenStack Load Balancing.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
pushd octavia_tempest_plugin/contrib/test_server
# we don't want to ship a binary blob that we didn't build ourself
rm -f test_server.bin
%if 0%{?suse_version}
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-s -w -extldflags -static' -o test_server.bin test_server.go
%else
# NOTE(jpena): the CentOS 8 build fails without this flag
go build -ldflags '-linkmode=external -compressdwarf=false' -o test_server.bin test_server.go
%endif
popd
%{py3_build}

%install
%{py3_install}

%files
%license LICENSE
%doc README.rst
%{python3_sitelib}/octavia_tempest_plugin
%{python3_sitelib}/*.egg-info

%changelog
